package com.yuke.cloud.service.uac.service;

import com.arronlong.httpclientutil.exception.HttpProcessException;
import com.github.pagehelper.PageInfo;
import com.yuke.cloud.common.base.dto.LoginAuthDto;
import com.yuke.cloud.common.base.dto.UserTokenDto;
import com.yuke.cloud.service.api.uac.dto.UserLoginInfoDto;
import com.yuke.cloud.service.uac.dto.TokenMainQueryDto;
import com.yuke.cloud.service.uac.entity.AccUserToken;
import com.yuke.cloud.common.core.support.IService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


/**
 * Created by wg on 2018/09/11.
 */
public interface AccUserTokenService extends IService<AccUserToken> {

    /**
     * 保存token.
     *
     * @param accessToken  the access token
     * @param refreshToken the refresh token
     * @param loginAuthDto the login auth dto
     * @param request      the request
     * @param updateFlag   true: update save, false: new save
     * @param oldAccessToken   old access token
     */
    void saveUserToken(String accessToken, String refreshToken, LoginAuthDto loginAuthDto, HttpServletRequest request, Boolean updateFlag, String oldAccessToken);

    /**
     * 获取token.
     *
     * @param accessToken the access token
     *
     * @return the by access token
     */
    UserTokenDto getByAccessToken(String accessToken);


    /**
     * 更新token.
     *
     * @param tokenDto     the token dto
     * @param loginAuthDto the login auth dto
     */
    void updateUacUserToken(UserTokenDto tokenDto, LoginAuthDto loginAuthDto);

    /**
     * 分页查询token列表.
     *
     * @param token the token
     *
     * @return the page info
     */
    PageInfo listTokenWithPage(TokenMainQueryDto token);

    /**
     * 刷新token.
     *
     * @param accessToken  the access token
     * @param refreshToken the refresh token
     * @param request      the request
     *
     * @return the string
     *
     * @throws HttpProcessException the http process exception
     */
    String refreshToken(String accessToken, String refreshToken, HttpServletRequest request) throws HttpProcessException;

    /**
     * 更新token离线状态.
     *
     * @return the int
     */
    int batchUpdateTokenOffLine();

    void deleteUacUserToken(String accessToken);

    List<UserLoginInfoDto> getUserDeviceToken(Long userId);
}
